home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 2 / ETO Development Tools 2.iso / Tools - Objects / MacApp / MacApp CD Release / MacApp 2.0.1 (Many Libraries) / Interfaces / CIncludes / UTranscriptView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-25  |  10.4 KB  |  229 lines  |  [TEXT/MPS ]

  1. /*[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]*/
  2. /* UTranscriptView.p */
  3. /* Copyright © 1985-1990 Apple Computer, Inc. All rights reserved. */
  4.         /* This unit implements the debug window, called the "transcript view." TTranscriptView 
  5.            is not
  6.         for the faint of heart, but it is possible to subclass it and override its methods, thereby
  7.         customizing the debug window's behavior (but not the debugger's behaviour since the debugger
  8.         USES a TTranscriptView). */
  9. #ifndef  __UTranscriptView__
  10. #define __UTranscriptView__  0
  11. #endif
  12. #if  ! __UTranscriptView__
  13. #define __UTranscriptView__  1
  14.  
  15.         /* • Auto-Include the requirements for this unit's interface. */
  16. #ifndef  __UMacApp__
  17. #include "UMacApp.h"
  18. #endif
  19.  
  20. const short kHMargin            = 4;
  21. const short kVMargin            = 4;
  22. const short kWWEol                ='\n';                    /* Character to consider the line break */
  23. const short kForceDepth            = 10;
  24.    /* Maximum number of forceOption changes that
  25.                                                          will be remembered */
  26.  
  27. typedef enum {WrForceOn, WrForceOff, WrForceUnchanged} WrForceOptions;         /* corresponds to
  28.                 TrcForceOptions. See TTranscriptView.ForceOutput and .EndForce. */
  29.  
  30. typedef unsigned char AText[10001];
  31. typedef AText *TextPtr;
  32. typedef TextPtr *TextHandle;                            /* Handy (get it? handy) way of referring to
  33.                                                          the stored text */
  34.  
  35. typedef short ALineLens[10001];                                   /* Kinda like a brain damaged TE, we
  36.                                                                 keep track of line lengths to aid
  37.                                                                 in rendering */
  38. typedef ALineLens *LineLensPtr;
  39. typedef LineLensPtr *LineLensHandle;
  40.  
  41. struct ForceState {
  42.    /* If toWindow is TRUE, output to the window.
  43.                                                          If toFile is TRUE, output to the redirect
  44.                                                          file. A stack of these is maintained by
  45.                                                          the TTranscriptView. */
  46.     Boolean toWindow;
  47.     Boolean toFile;
  48. };
  49.  
  50. class TTranscriptView : public TView {
  51.   public:
  52.    /* C A U T I O N -- this object is not really
  53.                                                          for public consumption. Use it at your own
  54.                                                          risk! */
  55.     Boolean fWrToWindow;
  56.        /* set to TRUE to enable writelns to window */
  57.     Boolean fWrToFile;                                    /* set to TRUE to enable writelns to file */
  58.     short fCols;                                        /* Max characters per line */
  59.     short fRows;                                        /* Number of lines saved. After this number
  60.                                                          of lines is exceeded, the oldest lines
  61.                                                          start falling off. */
  62.     short fTotal;
  63.        /* number of characters in all lines together
  64.                                                          */
  65.     TextHandle fText;                                    /* the ring buffer: blanks pad each line to
  66.                                                          80 chars */
  67.     LineLensHandle fLineLengths;                        /* linelength of each line.
  68.                                                          fBufferLinesLens^^[0] is # of characters
  69.                                                          in the line that begins with fText^^[0] */
  70.     LineLensHandle fLineStarts;                            /* offset into the fText handle of the first
  71.                                                          character in the line*/
  72.     short fFirstLineIndex;                                /* index where in the linelengths/starts
  73.                                                          array the top line starts */
  74.  
  75.     TextStyle fTextStyle;                                /* The style to with which to display the
  76.                                                          view */
  77.     FontInfo fFontInfo;                                    /* Font Info derived from the style */
  78.     short fFontHeight;                                    /* font height */
  79.  
  80.     Boolean fGotRefnum;                                    /* TRUE if there is a valid file refnum in
  81.                                                          fRefnum and fVRefNum. */
  82.     short fRefnum;                                        /* refnum for redirect output */
  83.     short fVRefNum;                                        /* vRefNum for redirected output. */
  84.  
  85.     ForceState fForceStack[10];
  86.        /* A stack of forced output
  87.                                                                            states. ForceOutput and
  88.                                                                            EndForce methods push
  89.                                                                            and pop this stack,
  90.  
  91.                                                                            respectively. */
  92.     short fForcePtr;                                    /* Top of the stack in fForceStack. */
  93.  
  94.     Ptr fHelpProc;                                        /* Call this to show help in response to the
  95.                                                          "Help" key. Default is no help. */
  96.     long fLastInsertionPointTime;                        /* Last time InsertionPoint was on */
  97.     Boolean fInsertionPointOn;                            /* True if InsertionPoint was turned on by
  98.                                                          idle */
  99.     Point fInsertionPt;
  100.        /* location of the insertion pt in Row, col */
  101.     short fLastCh;                                        /* last character typed */
  102.     RgnHandle fUpdateRgn;                                /* used in scrolling shortcut */
  103.  
  104.     virtual pascal Boolean DoIdle(IdlePhase phase);
  105.                 /* Blinks the insertion point. */
  106.  
  107.     virtual pascal TCommand *DoHelp(EventInfo *info, long *message);
  108.                 /* If fHelpis non-NIL, it is called. Called in response to a "Help" keypress. */
  109.  
  110.     virtual pascal TCommand *DoKeyCommand(short ch, short aKeyCode, EventInfo *info);
  111.  
  112.        /* Handles return, enter, arrows, home, end, and help keys only - they all perform the
  113.                 natural scrolling actions. Sets fLastCh to ch. */
  114.  
  115.     virtual pascal void Draw(Rect *area);
  116.                 /* Draws the visible portion of the stored text. */
  117.  
  118.     virtual pascal void Fields(pascal void (*DoToField)(StringPtr fieldName, Ptr fieldAddr, short 
  119.        fieldType, void *DoToField_StaticLink), void *DoToField_StaticLink);
  120.                 /* Used by the Inspector and the Debugger to display the contents of this classes
  121.                 fields. */
  122.  
  123.     virtual pascal void Free(void);
  124.                 /* Frees the text buffers before freeing SELF. Turns off output redirection if it is
  125.                 on. */
  126.  
  127.     virtual pascal Boolean HandleMouseDown(VPoint *theMouse, EventInfo *info, Point *hysteresis, 
  128.        TCommand **theCommand);
  129.                 /* Calls INHERITED HandleMouseDown. */
  130.  
  131.                 /* TranscriptWindow Specific methods */
  132.     virtual pascal void IRes(TDocument *itsDocument, TView *itsSuperView, Ptr *itsParams);
  133.  
  134.         /* Calls INHERITED IRes, SELF.CommonInit, then sets the view size to the correct size
  135.                 for the line width. */
  136.  
  137.     virtual pascal void AddText(Ptr textBuf, short byteCount);
  138.                 /* If fWrToWindow is currently TRUE, inserts the text in textBuf at the current
  139.                 insertion point. If fWrToFile is true, calls SELF.AddTextToFile to append textBuf
  140.                 to the redirect file. Can handle backspace characters and multiple line feeds in
  141.                 textBuf. */
  142.  
  143.     virtual pascal void AddTextToFile(Ptr textBuf, short byteCount);
  144.                 /* Appends the text in textBuf to the file fRefNum. */
  145.  
  146.     virtual pascal void RevealInsertionPoint(void);
  147.                 /* Scrolls the insertion point into view. */
  148.  
  149.     virtual pascal void EndForce(void);
  150.  
  151.         /* Sets fWrToWindow and fWrToFile to their prior states by popping the old states off
  152.                 the fForceStack stack. */
  153.  
  154.     virtual pascal void ForceOutput(WrForceOptions wrToWindow, WrForceOptions wrToFile);
  155.  
  156.         /* Pushes the current states of fWrToWindow and fWrToFile onto the fForceStack stack,
  157.  
  158.                 then sets them according to the arguments. If wrToWindow is not WrForceUnchanged,
  159.  
  160.                 fWrToWindow is set to the boolean value of "wrToWindow = WrForceOn"; otherwise
  161.                 fWrToWindow is left unchanged. Likewise for wrToFile and fWrToFile. */
  162.  
  163.     virtual pascal Rect GetInsertionPointRect(void);
  164.                 /* Returns the rectangle which defines the insertion point. */
  165.  
  166.     virtual pascal void CommonInit(TView *itsSuperView, short outputFont, short outputSize, short 
  167.        numLines, short numCharsPerLine);
  168.                 /* Performs general initialization of the view according to the arguments given. */
  169.  
  170.     virtual pascal void ITranscriptView(TView *itsSuperView, short outputFont, short outputSize, 
  171.        short numLines, short numCharsPerLine);
  172.  
  173.        /* Calls IView, then CommonInit, then sets the view size to the correct dimensions for
  174.                 the line width. */
  175.  
  176.     virtual pascal short PrevIndex(short ln);
  177.                 /* Returns the index into the line buffers for the line immediately preceeding ln,
  178.  
  179.                 wrapping backwards if necessary. */
  180.  
  181.     virtual pascal short SuccIndex(short ln);
  182.                 /* Returns the index into the line buffers for the line immediately succeeding ln,
  183.  
  184.                 wrapping to 0 if necessary. */
  185.  
  186.     virtual pascal short IndexToRow(short index);
  187.                 /* Converts index from an index into the line buffers into a relative line number in
  188.                 the output. */
  189.  
  190.     virtual pascal short RowToIndex(short row);
  191.                 /* Converts the output line number row into its index into the line buffers. */
  192.  
  193.     virtual pascal short IndexToLocal(short index);
  194.  
  195.        /* Converts an index into the line buffers into a vertical local drawing coordinate in
  196.                 the view. */
  197.  
  198.     virtual pascal void InstallTextStyle(TextStyle *theStyle);
  199.                 /* Makes theStyle the text style for the view, resizing as necessary. */
  200.  
  201.     virtual pascal short LocalToIndex(short local);
  202.                 /* Converts a vertical local drawing coordinate in the view into an index into the
  203.                 line buffers. */
  204.  
  205.     virtual pascal Point IndexColToLocal(short index, short col);
  206.                 /* Converts an index into the line buffers and a column number into local drawing
  207.                 coordinates. */
  208.  
  209.     virtual pascal short LocalToCol(short local);
  210.                 /* Converts a horizontal drawing coordinate into a column number. */
  211.  
  212.     virtual pascal OSErr Redirect(short vRefnum, StringPtr fileName);
  213.                 /* Opens the given file for the purpose of redirecting output. If fileName contains
  214.                 '>>', the file is opened for append; otherwise, it is truncated to zero length
  215.                 first. Does not set the fWrToFile state variable. */
  216.  
  217.     virtual pascal void Scroll(short howManyLines);
  218.                 /* Scrolls the view by howManyLines lines. */
  219.  
  220.     virtual pascal void RevealInsertionPointLine(void);
  221.                 /* Scrolls the insertion point into view. */
  222. };
  223.  
  224. extern pascal void IDUTranscriptView(void);
  225.         /* Displays the compile date and time of this unit. */
  226.  
  227. #endif
  228.  
  229.